package com.template.project.service.impl.inner;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fqj.fqjcommon.model.entity.InterfaceInfo;
import com.fqj.fqjcommon.service.InnerInterfaceInfoService;
import com.template.project.common.ErrorCode;
import com.template.project.exception.BusinessException;
import com.template.project.mapper.InterfaceInfoMapper;
import org.apache.commons.lang3.StringUtils;
import org.apache.dubbo.config.annotation.DubboService;

import javax.annotation.Resource;

@DubboService(timeout = 90000)
public class InnerInterfaceInfoServiceImpl implements InnerInterfaceInfoService {
	@Resource
	private InterfaceInfoMapper interfaceInfoMapper;

	@Override
	public InterfaceInfo getInterfaceInfo(String url, String method) {
		if (StringUtils.isAnyBlank(url,method)){
			throw new BusinessException(ErrorCode.PARAMS_ERROR);
		}
		QueryWrapper<InterfaceInfo> queryWrapper = new QueryWrapper<>();
		queryWrapper.eq("url",url);
		queryWrapper.eq("method",method);

		return interfaceInfoMapper.selectOne(queryWrapper);
	}

}
